package com.youku.expression.ast;

import org.apache.commons.lang3.math.NumberUtils;

import com.youku.expression.environment.Environment;

public class NegativeExpAst extends Ast {

	public NegativeExpAst(Ast ast) {
		super(ast);
	}

	public Ast exp() {
		return getChild(0);
	}

	@Override
	public String toString() {
		return "-" + exp();
	}

	@Override
	public Object eval(Environment environment) {
		double number = NumberUtils.toDouble(environment.get(token.value()).toString());
		return -number;
	}

}
